{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2c5b394a-6097-48f3-a6cf-8f09f952d095",
   "metadata": {},
   "source": [
    "功能说明\n",
    "\n",
    "    符号推导系统：建立了完整的德布罗意波方程体系，支持：\n",
    "\n",
    "        直接波长-动量关系（λ = h/p）\n",
    "\n",
    "        经典力学扩展形式（λ = h/(m*v)）\n",
    "\n",
    "    数值计算功能：\n",
    "\n",
    "        支持代入实际物理常数进行即时计算\n",
    "\n",
    "        自动处理科学计数法和大数运算\n",
    "\n",
    "    方程求解能力：\n",
    "\n",
    "        可以反推任意参数（速度、质量等）\n",
    "\n",
    "        支持符号公式推导\n",
    "\n",
    "    物理教学演示：\n",
    "\n",
    "        同时展示微观粒子（电子）和宏观物体的计算结果\n",
    "\n",
    "        直观显示量子效应在不同尺度下的显著差异\n",
    "\n",
    "扩展应用建议\n",
    "\n",
    "    相对论修正：引入洛伦兹因子 γ = 1/√(1 - v²/c²)，修改动量公式为 p = γm₀v\n",
    "\n",
    "    能量计算：结合动能公式 E_k = p²/(2m) 建立波长-能量关系\n",
    "\n",
    "    热力学系统：通过 mv = √(2mE) 分析热粒子的平均德布罗意波长\n",
    "\n",
    "    量子隧穿模拟：结合势垒参数计算隧穿概率时作为输入参数\n",
    "\n",
    "此程序可作为量子力学教学的基础工具，通过修改输入参数可直观观察各物理量间的相互关系和量子效应的变化规律。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "207962d1-262d-4c9d-b03e-39f956a08cd3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入符号计算库并定义符号变量\n",
    "var('λ h m v p c E_k')\n",
    "\n",
    "# 定义德布罗意基本关系式\n",
    "de_broglie_eq = λ == h / p               # 通用波长-动量关系\n",
    "momentum_eq = p == m*v                   # 经典动量定义\n",
    "combined_eq = de_broglie_eq.subs(p = m*v) # 组合后的波长公式 λ = h/(m*v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "196484f7-8fed-4eb2-9e78-38a85695517c",
   "metadata": {},
   "outputs": [],
   "source": [
    "#动质能三角形\n",
    "triangular = (p*c)^2 + (m*c^2)^2 == (E_k+m*c^2)^2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a416c8f0-e38e-45a5-afbc-a637702bfd66",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\left[p = -\\frac{\\sqrt{2 \\, E_{k} c^{2} m + E_{k}^{2}}}{c}, p = \\frac{\\sqrt{2 \\, E_{k} c^{2} m + E_{k}^{2}}}{c}\\right]\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\left[p = -\\frac{\\sqrt{2 \\, E_{k} c^{2} m + E_{k}^{2}}}{c}, p = \\frac{\\sqrt{2 \\, E_{k} c^{2} m + E_{k}^{2}}}{c}\\right]$"
      ],
      "text/plain": [
       "[p == -sqrt(2*E_k*c^2*m + E_k^2)/c, p == sqrt(2*E_k*c^2*m + E_k^2)/c]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "show(solve(triangular,p))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "8bcf87e6-7206-4dba-ad65-0379354a397d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "示例1：电子波长 = 7.28e-10 米\n"
     ]
    }
   ],
   "source": [
    "# ======================\n",
    "# 示例1：计算电子波长\n",
    "# ======================\n",
    "# 物理常量定义\n",
    "h_value = 6.626e-34       # 普朗克常数 (J·s)\n",
    "m_electron = 9.1e-31      # 电子质量 (kg)\n",
    "velocity = 1e6            # 电子速度 (m/s)\n",
    "\n",
    "# 代入数值计算\n",
    "electron_wavelength = combined_eq.subs(\n",
    "    h=h_value, \n",
    "    m=m_electron, \n",
    "    v=velocity\n",
    ").rhs()\n",
    "\n",
    "print(f\"示例1：电子波长 = {electron_wavelength.n():.2e} 米\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "a477d16c-51c4-471d-b100-75dbd5d98279",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "示例2：宏观物体波长 = 6.63e-34 米\n"
     ]
    }
   ],
   "source": [
    "# ======================\n",
    "# 示例2：宏观物体演示\n",
    "# ======================\n",
    "macro_wavelength = combined_eq.subs(\n",
    "    h=h_value,\n",
    "    m=1,                  # 1 kg物体\n",
    "    v=1                   # 1 m/s速度\n",
    ").rhs()\n",
    "\n",
    "print(f\"示例2：宏观物体波长 = {macro_wavelength.n():.2e} 米\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "f2abd258-98e7-4616-90e4-e2f79305e911",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "示例3：速度求解公式：\n",
      "v == h/(m*λ)\n",
      "计算得到的速度 = 7.28e+5 m/s\n"
     ]
    }
   ],
   "source": [
    "# ======================\n",
    "# 示例3：求解粒子速度\n",
    "# ======================\n",
    "# 已知波长和粒子质量时求速度\n",
    "speed_solution = solve(combined_eq, v)[0]\n",
    "print(\"\\n示例3：速度求解公式：\")\n",
    "print(speed_solution)\n",
    "\n",
    "# 代入具体数值（假设检测到电子波长为1e-9米）\n",
    "v_calculated = speed_solution.subs(\n",
    "    h=h_value,\n",
    "    m=m_electron,\n",
    "    λ=1e-9\n",
    ").rhs()\n",
    "\n",
    "print(f\"计算得到的速度 = {v_calculated.n():.2e} m/s\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "3854a73b-1a77-4c1c-9455-ae68276fa25a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "示例4：动量与波长关系公式：\n",
      "p == h/λ\n",
      "\n",
      "质量表达式：\n",
      "m == h/(v*λ)\n"
     ]
    }
   ],
   "source": [
    "# ======================\n",
    "# 示例4：符号推导演示\n",
    "# ======================\n",
    "# 推导动量与波长的关系\n",
    "momentum_relation = solve(de_broglie_eq, p)[0]\n",
    "print(\"\\n示例4：动量与波长关系公式：\")\n",
    "print(momentum_relation)\n",
    "\n",
    "# 推导质量表达式\n",
    "mass_relation = solve(combined_eq, m)[0]\n",
    "print(\"\\n质量表达式：\")\n",
    "print(mass_relation)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "7fe8996a-b973-4095-a15b-a59d3e8f5eb5",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[0;31mSignature:\u001b[0m      \u001b[0msolve\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
       "\u001b[0;31mDocstring:\u001b[0m     \n",
       "   Algebraically solve an equation or system of equations (over the\n",
       "   complex numbers) for given variables. Inequalities and systems of\n",
       "   inequalities are also supported.\n",
       "\n",
       "   INPUT:\n",
       "\n",
       "   * \"f\" -- equation or system of equations (given by a list or tuple)\n",
       "\n",
       "   * \"*args\" -- variables to solve for\n",
       "\n",
       "   * \"solution_dict\" -- boolean (default: \"False\"); if \"True\" or\n",
       "     nonzero, return a list of dictionaries containing the solutions.\n",
       "     If there are no solutions, return an empty list (rather than a\n",
       "     list containing an empty dictionary). Likewise, if there's only a\n",
       "     single solution, return a list containing one dictionary with\n",
       "     that solution.\n",
       "\n",
       "   There are a few optional keywords if you are trying to solve a\n",
       "   single equation.  They may only be used in that context.\n",
       "\n",
       "   * \"multiplicities\" -- boolean (default: \"False\"); if True, return\n",
       "     corresponding multiplicities.  This keyword is incompatible with\n",
       "     \"to_poly_solve=True\" and does not make any sense when solving\n",
       "     inequalities.\n",
       "\n",
       "   * \"explicit_solutions\" -- boolean (default: \"False\"); require that\n",
       "     all roots be explicit rather than implicit. Not used when solving\n",
       "     inequalities.\n",
       "\n",
       "   * \"to_poly_solve\" -- boolean (default: \"False\") or string; use\n",
       "     Maxima's \"to_poly_solver\" package to search for more possible\n",
       "     solutions, but possibly encounter approximate solutions. This\n",
       "     keyword is incompatible with \"multiplicities=True\" and is not\n",
       "     used when solving inequalities. Setting \"to_poly_solve\" to\n",
       "     'force' (string) omits Maxima's solve command (useful when some\n",
       "     solutions of trigonometric equations are lost).\n",
       "\n",
       "   * \"algorithm\" -- string (default: \"'maxima'\"); to use SymPy's\n",
       "     solvers set this to 'sympy'. Note that SymPy is always used for\n",
       "     diophantine equations. Another choice, if it is installed, is\n",
       "     'giac'.\n",
       "\n",
       "   * \"domain\" -- string (default: \"'complex'\"); setting this to 'real'\n",
       "     changes the way SymPy solves single equations; inequalities are\n",
       "     always solved in the real domain.\n",
       "\n",
       "   EXAMPLES:\n",
       "\n",
       "      sage: x, y = var('x, y')\n",
       "      sage: solve([x+y==6, x-y==4], x, y)\n",
       "      [[x == 5, y == 1]]\n",
       "      sage: solve([x^2+y^2 == 1, y^2 == x^3 + x + 1], x, y)\n",
       "      [[x == -1/2*I*sqrt(3) - 1/2, y == -sqrt(-1/2*I*sqrt(3) + 3/2)],\n",
       "       [x == -1/2*I*sqrt(3) - 1/2, y == sqrt(-1/2*I*sqrt(3) + 3/2)],\n",
       "       [x == 1/2*I*sqrt(3) - 1/2, y == -sqrt(1/2*I*sqrt(3) + 3/2)],\n",
       "       [x == 1/2*I*sqrt(3) - 1/2, y == sqrt(1/2*I*sqrt(3) + 3/2)],\n",
       "       [x == 0, y == -1],\n",
       "       [x == 0, y == 1]]\n",
       "      sage: solve([sqrt(x) + sqrt(y) == 5, x + y == 10], x, y)\n",
       "      [[x == -5/2*I*sqrt(5) + 5, y == 5/2*I*sqrt(5) + 5], [x == 5/2*I*sqrt(5) + 5, y == -5/2*I*sqrt(5) + 5]]\n",
       "      sage: solutions = solve([x^2+y^2 == 1, y^2 == x^3 + x + 1], x, y, solution_dict=True)\n",
       "      sage: for solution in solutions: print(\"{} , {}\".format(solution[x].n(digits=3), solution[y].n(digits=3)))\n",
       "      -0.500 - 0.866*I , -1.27 + 0.341*I\n",
       "      -0.500 - 0.866*I , 1.27 - 0.341*I\n",
       "      -0.500 + 0.866*I , -1.27 - 0.341*I\n",
       "      -0.500 + 0.866*I , 1.27 + 0.341*I\n",
       "      0.000 , -1.00\n",
       "      0.000 , 1.00\n",
       "\n",
       "   Whenever possible, answers will be symbolic, but with systems of\n",
       "   equations, at times approximations will be given by Maxima, due to\n",
       "   the underlying algorithm:\n",
       "\n",
       "      sage: sols = solve([x^3==y,y^2==x], [x,y]); sols[-1], sols[0] # abs tol 1e-15\n",
       "      ([x == 0, y == 0],\n",
       "       [x == (0.3090169943749475 + 0.9510565162951535*I),\n",
       "        y == (-0.8090169943749475 - 0.5877852522924731*I)])\n",
       "      sage: sols[0][0].rhs().pyobject().parent()\n",
       "      Complex Double Field\n",
       "\n",
       "      sage: solve([y^6==y],y)\n",
       "      [y == 1/4*sqrt(5) + 1/4*I*sqrt(2*sqrt(5) + 10) - 1/4,\n",
       "       y == -1/4*sqrt(5) + 1/4*I*sqrt(-2*sqrt(5) + 10) - 1/4,\n",
       "       y == -1/4*sqrt(5) - 1/4*I*sqrt(-2*sqrt(5) + 10) - 1/4,\n",
       "       y == 1/4*sqrt(5) - 1/4*I*sqrt(2*sqrt(5) + 10) - 1/4,\n",
       "       y == 1,\n",
       "       y == 0]\n",
       "      sage: solve( [y^6 == y], y)==solve( y^6 == y, y)\n",
       "      True\n",
       "\n",
       "   Here we demonstrate very basic use of the optional keywords:\n",
       "\n",
       "      sage: ((x^2-1)^2).solve(x)\n",
       "      [x == -1, x == 1]\n",
       "      sage: ((x^2-1)^2).solve(x,multiplicities=True)\n",
       "      ([x == -1, x == 1], [2, 2])\n",
       "      sage: solve(sin(x)==x,x)\n",
       "      [x == sin(x)]\n",
       "      sage: solve(sin(x)==x,x,explicit_solutions=True)\n",
       "      []\n",
       "      sage: solve(abs(1-abs(1-x)) == 10, x)\n",
       "      [abs(abs(x - 1) - 1) == 10]\n",
       "      sage: solve(abs(1-abs(1-x)) == 10, x, to_poly_solve=True)\n",
       "      [x == -10, x == 12]\n",
       "\n",
       "      sage: from sage.symbolic.expression import Expression\n",
       "      sage: Expression.solve(x^2==1,x)\n",
       "      [x == -1, x == 1]\n",
       "\n",
       "   We must solve with respect to actual variables:\n",
       "\n",
       "      sage: z = 5\n",
       "      sage: solve([8*z + y == 3, -z +7*y == 0],y,z)\n",
       "      Traceback (most recent call last):\n",
       "      ...\n",
       "      TypeError: 5 is not a valid variable.\n",
       "\n",
       "   If we ask for dictionaries containing the solutions, we get them:\n",
       "\n",
       "      sage: solve([x^2-1],x,solution_dict=True)\n",
       "      [{x: -1}, {x: 1}]\n",
       "      sage: solve([x^2-4*x+4],x,solution_dict=True)\n",
       "      [{x: 2}]\n",
       "      sage: res = solve([x^2 == y, y == 4],x,y,solution_dict=True)\n",
       "      sage: for soln in res: print(\"x: %s, y: %s\" % (soln[x], soln[y]))\n",
       "      x: 2, y: 4\n",
       "      x: -2, y: 4\n",
       "\n",
       "   If there is a parameter in the answer, that will show up as a new\n",
       "   variable.  In the following example, \"r1\" is an arbitrary constant\n",
       "   (because of the \"r\"):\n",
       "\n",
       "      sage: forget()\n",
       "      sage: x, y = var('x,y')\n",
       "      sage: solve([x+y == 3, 2*x+2*y == 6],x,y)\n",
       "      [[x == -r1 + 3, y == r1]]\n",
       "\n",
       "      sage: var('b, c')\n",
       "      (b, c)\n",
       "      sage: solve((b-1)*(c-1), [b,c])\n",
       "      [[b == 1, c == r...], [b == r..., c == 1]]\n",
       "\n",
       "   Especially with trigonometric functions, the dummy variable may be\n",
       "   implicitly an integer (hence the \"z\"):\n",
       "\n",
       "      sage: solve( sin(x)==cos(x), x, to_poly_solve=True)\n",
       "      [x == 1/4*pi + pi*z...]\n",
       "      sage: solve([cos(x)*sin(x) == 1/2, x+y == 0],x,y)\n",
       "      [[x == 1/4*pi + pi*z..., y == -1/4*pi - pi*z...]]\n",
       "\n",
       "   Expressions which are not equations are assumed to be set equal to\n",
       "   zero, as with x in the following example:\n",
       "\n",
       "      sage: solve([x, y == 2],x,y)\n",
       "      [[x == 0, y == 2]]\n",
       "\n",
       "   If \"True\" appears in the list of equations it is ignored, and if\n",
       "   \"False\" appears in the list then no solutions are returned. E.g.,\n",
       "   note that the first \"3==3\" evaluates to \"True\", not to a symbolic\n",
       "   equation.\n",
       "\n",
       "      sage: solve([3==3, 1.00000000000000*x^3 == 0], x)\n",
       "      [x == 0]\n",
       "      sage: solve([1.00000000000000*x^3 == 0], x)\n",
       "      [x == 0]\n",
       "\n",
       "   Here, the first equation evaluates to \"False\", so there are no\n",
       "   solutions:\n",
       "\n",
       "      sage: solve([1==3, 1.00000000000000*x^3 == 0], x)\n",
       "      []\n",
       "\n",
       "   Completely symbolic solutions are supported:\n",
       "\n",
       "      sage: var('s,j,b,m,g')\n",
       "      (s, j, b, m, g)\n",
       "      sage: sys = [ m*(1-s) - b*s*j, b*s*j-g*j ]\n",
       "      sage: solve(sys,s,j)\n",
       "      [[s == 1, j == 0], [s == g/b, j == (b - g)*m/(b*g)]]\n",
       "      sage: solve(sys,(s,j))\n",
       "      [[s == 1, j == 0], [s == g/b, j == (b - g)*m/(b*g)]]\n",
       "      sage: solve(sys,[s,j])\n",
       "      [[s == 1, j == 0], [s == g/b, j == (b - g)*m/(b*g)]]\n",
       "\n",
       "      sage: z = var('z')\n",
       "      sage: solve((x-z)^2==2, x)\n",
       "      [x == z - sqrt(2), x == z + sqrt(2)]\n",
       "\n",
       "   Inequalities can be also solved:\n",
       "\n",
       "      sage: solve(x^2>8,x)\n",
       "      [[x < -2*sqrt(2)], [x > 2*sqrt(2)]]\n",
       "      sage: x,y = var('x,y'); (ln(x)-ln(y)>0).solve(x)\n",
       "      [[log(x) - log(y) > 0]]\n",
       "      sage: x,y = var('x,y'); (ln(x)>ln(y)).solve(x)  # random\n",
       "      [[0 < y, y < x, 0 < x]]\n",
       "      [[y < x, 0 < y]]\n",
       "\n",
       "   A simple example to show the use of the keyword \"multiplicities\":\n",
       "\n",
       "      sage: ((x^2-1)^2).solve(x)\n",
       "      [x == -1, x == 1]\n",
       "      sage: ((x^2-1)^2).solve(x,multiplicities=True)\n",
       "      ([x == -1, x == 1], [2, 2])\n",
       "      sage: ((x^2-1)^2).solve(x,multiplicities=True,to_poly_solve=True)\n",
       "      Traceback (most recent call last):\n",
       "      ...\n",
       "      NotImplementedError: to_poly_solve does not return multiplicities\n",
       "\n",
       "   Here is how the \"explicit_solutions\" keyword functions:\n",
       "\n",
       "      sage: solve(sin(x)==x,x)\n",
       "      [x == sin(x)]\n",
       "      sage: solve(sin(x)==x,x,explicit_solutions=True)\n",
       "      []\n",
       "      sage: solve(x*sin(x)==x^2,x)\n",
       "      [x == 0, x == sin(x)]\n",
       "      sage: solve(x*sin(x)==x^2,x,explicit_solutions=True)\n",
       "      [x == 0]\n",
       "\n",
       "   The following examples show the use of the keyword \"to_poly_solve\":\n",
       "\n",
       "      sage: solve(abs(1-abs(1-x)) == 10, x)\n",
       "      [abs(abs(x - 1) - 1) == 10]\n",
       "      sage: solve(abs(1-abs(1-x)) == 10, x, to_poly_solve=True)\n",
       "      [x == -10, x == 12]\n",
       "\n",
       "      sage: var('Q')\n",
       "      Q\n",
       "      sage: solve(Q*sqrt(Q^2 + 2) - 1, Q)\n",
       "      [Q == 1/sqrt(Q^2 + 2)]\n",
       "\n",
       "   The following example is a regression in Maxima 5.39.0. It used to\n",
       "   be possible to get one more solution here, namely \"1/sqrt(sqrt(2) +\n",
       "   1)\", see https://sourceforge.net/p/maxima/bugs/3276/:\n",
       "\n",
       "      sage: solve(Q*sqrt(Q^2 + 2) - 1, Q, to_poly_solve=True)\n",
       "      [Q == -sqrt(-sqrt(2) - 1), Q == sqrt(sqrt(2) + 1)*(sqrt(2) - 1)]\n",
       "\n",
       "   An effort is made to only return solutions that satisfy the current\n",
       "   assumptions:\n",
       "\n",
       "      sage: solve(x^2==4, x)\n",
       "      [x == -2, x == 2]\n",
       "      sage: assume(x<0)\n",
       "      sage: solve(x^2==4, x)\n",
       "      [x == -2]\n",
       "      sage: solve((x^2-4)^2 == 0, x, multiplicities=True)\n",
       "      ([x == -2], [2])\n",
       "      sage: solve(x^2==2, x)\n",
       "      [x == -sqrt(2)]\n",
       "      sage: z = var('z')\n",
       "      sage: solve(x^2==2-z, x)\n",
       "      [x == -sqrt(-z + 2)]\n",
       "      sage: assume(x, 'rational')\n",
       "      sage: solve(x^2 == 2, x)\n",
       "      []\n",
       "\n",
       "   In some cases it may be worthwhile to directly use \"to_poly_solve\"\n",
       "   if one suspects some answers are being missed:\n",
       "\n",
       "      sage: forget()\n",
       "      sage: solve(cos(x)==0, x)\n",
       "      [x == 1/2*pi]\n",
       "      sage: solve(cos(x)==0, x, to_poly_solve=True)\n",
       "      [x == 1/2*pi]\n",
       "      sage: solve(cos(x)==0, x, to_poly_solve='force')\n",
       "      [x == 1/2*pi + pi*z...]\n",
       "\n",
       "   The same may also apply if a returned unsolved expression has a\n",
       "   denominator, but the original one did not:\n",
       "\n",
       "      sage: solve(cos(x) * sin(x) == 1/2, x, to_poly_solve=True)\n",
       "      [sin(x) == 1/2/cos(x)]\n",
       "      sage: solve(cos(x) * sin(x) == 1/2, x, to_poly_solve=True, explicit_solutions=True)\n",
       "      [x == 1/4*pi + pi*z...]\n",
       "      sage: solve(cos(x) * sin(x) == 1/2, x, to_poly_solve='force')\n",
       "      [x == 1/4*pi + pi*z...]\n",
       "\n",
       "   We use \"use_grobner\" in Maxima if no solution is obtained from\n",
       "   Maxima's \"to_poly_solve\":\n",
       "\n",
       "      sage: x,y = var('x y')\n",
       "      sage: c1(x,y) = (x-5)^2+y^2-16\n",
       "      sage: c2(x,y) = (y-3)^2+x^2-9\n",
       "      sage: solve([c1(x,y),c2(x,y)],[x,y])\n",
       "      [[x == -9/68*sqrt(55) + 135/68, y == -15/68*sqrt(55) + 123/68],\n",
       "       [x == 9/68*sqrt(55) + 135/68, y == 15/68*sqrt(55) + 123/68]]\n",
       "\n",
       "   We use SymPy for Diophantine equations, see\n",
       "   \"Expression.solve_diophantine\":\n",
       "\n",
       "      sage: assume(x, 'integer')\n",
       "      sage: assume(z, 'integer')\n",
       "      sage: solve((x-z)^2==2, x)\n",
       "      []\n",
       "\n",
       "      sage: forget()\n",
       "\n",
       "   The following shows some more of SymPy's capabilities that cannot\n",
       "   be handled by Maxima:\n",
       "\n",
       "      sage: _ = var('t')\n",
       "      sage: r = solve([x^2 - y^2/exp(x), y-1], x, y, algorithm='sympy')\n",
       "      sage: (r[0][x], r[0][y])\n",
       "      (2*lambert_w(-1/2), 1)\n",
       "      sage: solve(-2*x**3 + 4*x**2 - 2*x + 6 > 0, x, algorithm='sympy')\n",
       "      [x < 1/3*(1/2)^(1/3)*(9*sqrt(77) + 79)^(1/3) + 2/3*(1/2)^(2/3)/(9*sqrt(77) + 79)^(1/3) + 2/3]\n",
       "      sage: solve(sqrt(2*x^2 - 7) - (3 - x),x,algorithm='sympy')\n",
       "      [x == -8, x == 2]\n",
       "      sage: solve(sqrt(2*x + 9) - sqrt(x + 1) - sqrt(x + 4),x,algorithm='sympy')\n",
       "      [x == 0]\n",
       "      sage: r = solve([x + y + z + t, -z - t], x, y, z, t, algorithm='sympy')\n",
       "      sage: (r[0][x], r[0][z])\n",
       "      (-y, -t)\n",
       "      sage: r = solve([x^2+y+z, y+x^2+z, x+y+z^2], x, y,z, algorithm='sympy')\n",
       "      sage: (r[0][x], r[0][y])\n",
       "      (z, -(z + 1)*z)\n",
       "      sage: (r[1][x], r[1][y])\n",
       "      (-z + 1, -z^2 + z - 1)\n",
       "      sage: solve(abs(x + 3) - 2*abs(x - 3),x,algorithm='sympy',domain='real')\n",
       "      [x == 1, x == 9]\n",
       "\n",
       "   We cannot translate all results from SymPy but we can at least\n",
       "   print them:\n",
       "\n",
       "      sage: solve(sinh(x) - 2*cosh(x),x,algorithm='sympy')\n",
       "      [ImageSet(Lambda(_n, I*(2*_n*pi + pi/2) + log(sqrt(3))), Integers),\n",
       "       ImageSet(Lambda(_n, I*(2*_n*pi - pi/2) + log(sqrt(3))), Integers)]\n",
       "      sage: solve(2*sin(x) - 2*sin(2*x), x,algorithm='sympy')\n",
       "      [ImageSet(Lambda(_n, 2*_n*pi), Integers),\n",
       "       ImageSet(Lambda(_n, 2*_n*pi + pi), Integers),\n",
       "       ImageSet(Lambda(_n, 2*_n*pi + 5*pi/3), Integers),\n",
       "       ImageSet(Lambda(_n, 2*_n*pi + pi/3), Integers)]\n",
       "\n",
       "      sage: solve(x^5 + 3*x^3 + 7, x, algorithm='sympy')[0] # known bug\n",
       "      complex_root_of(x^5 + 3*x^3 + 7, 0)\n",
       "\n",
       "   A basic interface to Giac is provided:\n",
       "\n",
       "      sage: solve([(2/3)^x-2], [x], algorithm='giac')\n",
       "      ...[[-log(2)/(log(3) - log(2))]]\n",
       "\n",
       "      sage: f = (sin(x) - 8*cos(x)*sin(x))*(sin(x)^2 + cos(x)) - (2*cos(x)*sin(x) - sin(x))*(-2*sin(x)^2 + 2*cos(x)^2 - cos(x))\n",
       "      sage: solve(f, x, algorithm='giac')\n",
       "      ...[-2*arctan(sqrt(2)), 0, 2*arctan(sqrt(2)), pi]\n",
       "\n",
       "      sage: x, y = SR.var('x,y')\n",
       "      sage: solve([x+y-4,x*y-3],[x,y],algorithm='giac')\n",
       "      [[1, 3], [3, 1]]\n",
       "\u001b[0;31mInit docstring:\u001b[0m Initialize self.  See help(type(self)) for accurate signature.\n",
       "\u001b[0;31mFile:\u001b[0m           /usr/lib/python3.12/site-packages/sage/symbolic/relation.py\n",
       "\u001b[0;31mType:\u001b[0m           function"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "solve?"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "SageMath 10.5",
   "language": "sage",
   "name": "sagemath"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
